package com.gph.saviorframework.wf.service.impl;

import com.gph.saviorframework.wf.dao.ApproveInfoDao;
import com.gph.saviorframework.wf.model.ApproveInfo;
import com.gph.saviorframework.wf.service.ActivitiApproveInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * Created by root on 16-8-8.
 */
@Component
public class ActivitiApproveInfoServiceImpl implements ActivitiApproveInfoService {

    @Autowired
    private ApproveInfoDao approveInfoDao;

    @Transactional
    public void save(ApproveInfo approveInfo) {
        approveInfoDao.save(approveInfo);
    }

    /**
     * 根据编号获取审批信息
     *
     * @param id
     * @return
     */
    @Transactional(readOnly = true)
    public ApproveInfo get(String id) {
        return approveInfoDao.get(id);
    }

    /**
     * 根据审批编号获取所有的审批信息
     *
     * @param applyId
     * @return
     */
    @Transactional(readOnly = true)
    public List<ApproveInfo> findByApplyId(String applyId) {
        return approveInfoDao.findByApplyId(applyId);
    }

    /**
     * 根据任务编号获取所有的审批信息
     *
     * @param taskId
     * @return
     */
    @Transactional(readOnly = true)
    public List<ApproveInfo> findByTaskId(String taskId) {
        return approveInfoDao.findByTaskId(taskId);
    }

    /**
     * 根据任务key获取所有的审批信息
     *
     * @param taskKey
     * @return
     */
    @Transactional(readOnly = true)
    public List<ApproveInfo> findByTaskKey(String taskKey) {
        return approveInfoDao.findByTaskKey(taskKey);
    }

    /**
     * 根据流程实例编号获取所有的审批信息
     *
     * @param processInsId
     * @return
     */
    @Transactional(readOnly = true)
    public List<ApproveInfo> findByProcessInsId(String processInsId) {
        return approveInfoDao.findByProcessInsId(processInsId);
    }

    /**
     * 根据流程实例编号删除审批信息
     *
     * @param processInsId
     */
    public void deleteByProcessInsId(String processInsId) {
        approveInfoDao.deleteByProcessInsId(processInsId);
    }
}
